package com.gcs.k8s01.controller;

import com.gcs.k8s01.aspect.SysLog;
import com.gcs.k8s01.dao.UserInfoDao;
import com.gcs.k8s01.entity.UserInfoEntity;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.data.domain.Example;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description TODO
 * @Author guosong
 * @Date 2023/11/17 8:43
 */
@RestController
@Api(tags = "用户管理")
public class HelloController {
    @Resource
    private UserInfoDao userInfoDao;
    @PostMapping("addUser")
    @SysLog(desc = "添加用户",reqData ="#userInfoEntity.name")
    @ApiOperation("添加用户")
    public UserInfoEntity addUserInfo(UserInfoEntity userInfoEntity){
        return  userInfoDao.save(userInfoEntity);
    }



    @GetMapping("listUser")
    @ApiOperation("查找用户")
    @SysLog(desc = "查找用户",reqData ="#userInfoEntity")
    public List<UserInfoEntity> listUserInfo( UserInfoEntity userInfoEntity){
        return userInfoDao.findAll(Example.of(userInfoEntity));
    }
}
